package com.lzx.adx.report.util.helper;

import com.alibaba.fastjson.JSON;
import com.lzx.adx.report.dto.AccountDTO;
import com.lzx.adx.report.dto.ReportDTO;
import com.lzx.adx.report.model.vivo.ViVoRequest;
import org.apache.commons.lang3.StringUtils;

public class VivoHelper {
    public static String getUserType(ReportDTO reportDTO) {
        ViVoRequest viVoRequest = JSON.parseObject(reportDTO.getExtend(), ViVoRequest.class);
        if(StringUtils.isNotBlank(viVoRequest.getImei()) && !viVoRequest.getImei().equals("__IMEI__")){
            return "IMEI_MD5";
        }else if(StringUtils.isNotBlank(viVoRequest.getOaid()) && !viVoRequest.getOaid().equals("__OAIDPLAIN__")){
            return "OAID";
        }else  if(StringUtils.isNotBlank(viVoRequest.getOaidMd5()) && !viVoRequest.getOaidMd5().equals("__OAID__")){
            return "OAID_MD5";
        }
        return "OTHER";
    }

    public static String getUserId(ReportDTO reportDTO) {
        ViVoRequest viVoRequest = JSON.parseObject(reportDTO.getExtend(), ViVoRequest.class);
        if(StringUtils.isNotBlank(viVoRequest.getImei()) && !viVoRequest.getImei().equals("__IMEI__")){
            return viVoRequest.getImei();
        }else if(StringUtils.isNotBlank(viVoRequest.getOaid())  && !viVoRequest.getOaid().equals("__OAIDPLAIN__")){
            return viVoRequest.getOaid();
        }else  if(StringUtils.isNotBlank(viVoRequest.getOaidMd5()) && !viVoRequest.getOaidMd5().equals("__OAID__")){
            return viVoRequest.getOaidMd5();
        }
        return "OTHER";
    }
}
